import { FormSchema } from '/@/components/Table';
import { h } from 'vue';
import { Tinymce } from '/@/components/Tinymce/index';
import { getDepartment } from '/@/api/system/system';
export const formSchema: FormSchema[] = [
  {
    field: 'userRealName', //receiver
    label: '收件人',
    component: 'Input',
    colProps: { span: 23 },
    slot: 'userRealName',
    required: true,
  },
  {
    field: 'deptCodes',
    label: '部门',
    component: 'ApiTreeSelect',
    defaultValue: [],
    required: true,
    colProps: {
      span: 23,
    },
    componentProps: {
      api: getDepartment,
      multiple: true,
      maxTagCount: 3,
      resultField: 'list',
      fieldNames: {
        label: 'name',
        key: 'code',
        value: 'code',
      },
      treeNodeFilterProp: 'name',
      treeDefaultExpandAll: true,
      getPopupContainer: () => document.body,
    },
    ifShow: false,
  },
  {
    field: 'csms',
    label: ' ',
    component: 'Input',
    colProps: { span: 23 },
    slot: 'csms',
  },
  {
    field: 'userRealName1', //receiver1
    label: '抄送',
    component: 'Input',
    colProps: { span: 23 },
    slot: 'userRealName1',
    ifShow: false,
  },
  // {
  //   field: 'userRealName2', //receiver2
  //   label: '密送',
  //   component: 'Input',
  //   colProps: { span: 23 },
  //   slot: 'userRealName2',
  //   ifShow: false,
  // },
  {
    field: 'title',
    label: '主题',
    component: 'Input',
    colProps: { span: 23 },
    required: true,
  },
  {
    field: 'content',
    label: '正文',
    component: 'Input',
    required: true,
    colProps: { span: 23 },
    // slot: 'content',
    render: ({ model, field }) => {
      return h(Tinymce, {
        value: model[field],
        showImageUpload: false,
        plugins:
          'advlist autolink autosave  directionality  fullscreen hr insertdatetime link lists nonbreaking noneditable pagebreak paste preview print save searchreplace spellchecker tabfocus  template  textpattern visualblocks visualchars wordcount',
        toolbar: [
          'fontsizeselect lineheight searchreplace bold italic underline strikethrough alignleft aligncenter alignright outdent indent undo redo removeformat subscript superscript',
          'hr bullist numlist link  preview pagebreak insertdatetime  forecolor backcolor fullscreen',
        ],
        onChange: (value: string) => {
          model[field] = value;
        },
      });
    },
  },
  {
    field: 'att', //att1 att2
    label: '附件',
    component: 'Input',
    colProps: { span: 23 },
    slot: 'att',
  },
  {
    field: 'att2',
    label: ' ',
    component: 'Input',
    colProps: { span: 23 },
    slot: 'att2',
    ifShow: false,
  },
  {
    field: 'send_now',
    label: '发送时间',
    component: 'Input',
    colProps: { span: 23 },
    slot: 'send_now',
  },
  // {
  //   field: 'isToOutBox',
  //   label: '保存到发件箱',
  //   component: 'RadioButtonGroup',
  //   colProps: { span: 23 },
  //   defaultValue: 'true',
  //   componentProps: {
  //     options: [
  //       { label: '是', value: 'true' },
  //       { label: '否', value: 'false' },
  //     ],
  //   },
  // },
  {
    field: 'receipt_state',
    label: '回执',
    component: 'RadioButtonGroup',
    colProps: { span: 23 },
    componentProps: {
      options: [
        { label: '是', value: 1 },
        { label: '否', value: 0 },
      ],
    },
  },
  {
    field: 'msg_level',
    label: '等级',
    component: 'RadioButtonGroup',
    colProps: { span: 23 },
    componentProps: {
      options: [
        { label: '普通', value: 0 },
        { label: '紧急', value: 1 },
      ],
    },
  },
];
export const radioStyle = {
  display: 'flex',
  height: '30px',
  lineHeight: '30px',
};
